<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!-- 定义项目路径   url标签可以  -->
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>采购商账户管理</title>
	<jsp:include page="../inc.jsp"/>
<style type="text/css">
.u_logo{margin: 12px 0 24px;}
.u_logo a img{ border:0;}
.mod-bread {background: #f1f1f1;height: 46px;}
.head{width:1300px;margin:0 auto;line-height:42px;font-size:14px;font-weight:bold;}
.mod-bread .bread-left {float: left;font-size: 14px;font-weight: bold;height: 46px;line-height: 46px;text-align: right;width: 137px;}
.mod-bread .bread-right {float: right;height: 46px;line-height: 46px;padding-right: 20px;}
</style>
<link href="${ctx }/jslib/layui/css/layui.css" rel="stylesheet" type="text/css" />
<!-- 引入jQuery -->
<script src="${ctx}/jslib/jquery-1.8.3.js" type="text/javascript" charset="utf-8"></script>
<!-- 引入layer -->
<script src="${ctx}/jslib/layer/layer.js" type="text/javascript" charset="utf-8"></script>
<!-- 引入EasyUI -->
<link id="easyuiTheme" rel="stylesheet" href="${ctx}/jslib/easyui1.3.3/themes/<c:out value="${cookie.easyuiThemeName.value}" default="default"/>/easyui.css" type="text/css">
<link id="easyuiTheme" rel="stylesheet" href="${ctx}/jslib/easyui1.3.3/themes/icon.css" type="text/css">
<script type="text/javascript" src="${ctx}/jslib/easyui1.3.3/jquery.easyui.min.js" charset="utf-8"></script>
<script type="text/javascript" src="${ctx}/jslib/easyui1.3.3/locale/easyui-lang-zh_CN.js" charset="utf-8"></script>
<!-- 扩展Jquery -->
<script type="text/javascript" src="${ctx}/jslib/extJquery.js" charset="utf-8"></script>

<link href="${ctx }/jslib/regvalid/main.css" rel="stylesheet" type="text/css" />
<!--必要样式-->
<link href="${ctx }/jslib/regvalid/user_form.css" rel="stylesheet" type="text/css" />
<script src="${ctx }/jslib/jquery.form.js" type="text/javascript"></script>
<script type="text/javascript" src="${ctx }/jslib/cityselect/js/jquery.cityselect.js"></script>
<script src="${ctx }/jslib/regvalid/formValidator-4.1.1.js" type="text/javascript"></script>
<script src="${ctx }/jslib/regvalid/formValidatorRegex.js" type="text/javascript"></script>
<!-- 验证工具类 -->
<script type="text/javascript" src="${ctx}/jslib/biz/commonConverter.js" charset="utf-8"></script>
<script type="text/javascript">
$(document).ready(function(){
	//页面初始化
	$.ajax({
		type:"get",
		url:'${ctx}/organization/getOrgInfo?temp='+Math.random(),
		dataType:'json',
		async:true,
		success:function(data){
				$("#nickname").val('${sessionInfo.name}'); //昵称
				$("#com_name").text(data.name); //公司名称
				$("#prov_city").text(CommonConverter.toEmptyString(data.prov)+CommonConverter.toEmptyString(data.city)); //公司位置
				$("#location").val(CommonConverter.toEmptyString(data.address));  //具体地址
				$("#contacts").val(CommonConverter.toEmptyString(data.contact));  //联系人 
				$("#mobile").val(CommonConverter.toEmptyString(data.mobile));  //手机
				$("#telphone").val(CommonConverter.toEmptyString(data.telphone));  //公司电话
				$("#mail").val('${sessionInfo.email}'); //邮箱
				$("#bankName").text(data.bankName); //开户银行
				$("#bankCard").text(data.bankCard); //卡号
				$("#bankUser").text(data.bankUser); //持卡人
				$("#zzfile").attr("src",data.zzPath);
				$("#showfile").attr("src",data.zzPath);
				//$("#remark").text(data.remark);
		}
	});
	$("#city_3").citySelect({nodata:"none",required:false});
	$.formValidator.initConfig({theme:"baidu",mode:"AutoTip",submitOnce:true,formID:"user_form_0",
		submitAfterAjaxPrompt : '有数据正在异步验证，请稍等...'
	});
	
	
	$("#nickname").formValidator({onShowText:"请输入昵称",onFocus:"必须为汉字、英文字母、数字、不包含特殊字符",onCorrect:"输入正确",tipCss:{height:36,width:320}}).inputValidator({min:1,max:20,onError:"输入的长度不正确"}).regexValidator({regExp:"company",dataType:"enum",onError:"格式不正确"});
	$("#company").formValidator({onShowText:"请输入公司名称",onFocus:"必须为汉字、英文字母、数字、不包含特殊字符",onCorrect:"输入正确",tipCss:{height:36,width:320}}).inputValidator({min:1,max:200,onError:"输入的长度不正确"}).regexValidator({regExp:"company",dataType:"enum",onError:"格式不正确"});
	$("#location").formValidator({onShowText:"请输入地址",onFocus:"必须为汉字、英文字母、数字、不包含特殊字符",onCorrect:"输入正确",tipCss:{height:36,width:320}}).inputValidator({min:1,max:200,onError:"输入的长度不正确"}).regexValidator({regExp:"company",dataType:"enum",onError:"格式不正确"});
	$("#contacts").formValidator({onShowText:"请输入真实姓名",onFocus:"请输入真实姓名",onCorrect:"输入正确",tipCss:{height:36,width:320}}).inputValidator({min:1,max:50,onError:"输入的长度不正确"}).regexValidator({regExp:"company",dataType:"enum",onError:"格式不正确"});
	$("#mobile").formValidator({onShowText:"请输入联系人手机",onFocus:"请输入手机号方便找回密码",onCorrect:"输入正确",tipCss:{height:36,width:320}}).inputValidator({min:1,max:50,onError:"输入的长度不正确"}).regexValidator({regExp:"mobile",dataType:"enum",onError:"格式不正确"});
	$("#city").formValidator({onShowText:"请选择市区",onFocus:"请选择市区",onCorrect:"输入正确",tipCss:{height:36,width:320}}).inputValidator({min:1,max:1000,onError:"你没有选择市区"});

	$("#mail").formValidator({onShowText:"请输入邮箱",onFocus:"请输入常用邮箱，通过验证后可用于登陆和找回密码",defaultValue:"@",tipCss:{height:36,width:320}}).inputValidator({min:6,max:60,onError:"请输入邮箱"}).regexValidator({regExp:"email",dataType:"enum",onError:"邮箱格式不正确"});

});

//点击提交
function audit(type){
	progressLoad();
	var temp = $.formValidator.pageIsValid("1");
	if (!temp) {
		progressClose();
		return;
	}
	
	var param={};//存储所有参数
	var nickname=$("#nickname").val(); //昵称
	var address=$("#location").val();  //具体地址
	var contact=$("#contacts").val();  //联系人 
	var mobile=$("#mobile").val();  //手机
	var telphone=$("#telphone").val();  //公司电话
	var email=$("#mail").val(); //邮箱
	
	param={"nickname":nickname,
			"address":address,
			"contact":contact,
			"mobile":mobile,
			"telphone":telphone,
			"email":email,
			"type":type
			};
	//发送ajax请求  
	$.ajax({
		type:"post",
		url:"${ctx}/user/updateInfo?temp="+Math.random(),
		dataType:'json',
		//contentType:'application/json;charset=utf-8',
		data:param,
		success:function(data){
			progressClose();
			if(data.success){
				layer.alert('保存成功！',{skin:'layui-layer-lan',title: ['系统提示', 'background-color:#00B2EE; color:#fff;'],closeBtn: 0}, function(index){
					window.location.reload();
					layer.close(index);
				});
			}else{
				layer.alert("保存失败！");
			}
		},
		error:function(msg){
			progressClose();
			layer.alert("请检查您的网络，并重试！");
		}
	});
}
 function showPic(){
    layer.open({
        type: 1,
        title: false,
        closeBtn: 1,
        skin: 'layui-layer-nobg', //没有背景色
        shadeClose: true,
        content:$('#img').html()
    });
}
</script>
</head>

<body>
<jsp:include page="../head.jsp"></jsp:include>
<div class="mod-bread clearfix">
	<div style="width:100%;background:#f1f1f1;">
		<div class="head"> 用户信息</div>
    	<!--  <div class="bread-right"> 已有帐号？<a id="login" href="${ctx }/admin/index">马上登录</a></div> -->
	</div>
</div>

<div class="div" style="padding-top:20px;width:1300px;background:white;">
<p>温馨提示：如需修改银行卡信息，请联系我们</p>
<form id="user_form_0" class="user_form" style="margin-left:500px;" method="post" action="${ctx }/user/reg">
<p>
<label id="label_username" for="username">用户名:</label>
<label style="text-align: left;">${sessionInfo.loginname}</label>
<!--  <input id="username" readonly class="user_input" type="text" name="username" > -->
</p>

<p>
<label id="label_username" for="username">昵称:</label>
<input id="nickname" class="user_input" type="text" name="nickname" >
</p>

<p>
<label id="label_company" for="company">公司名称:</label>
<label id="com_name" style="text-align: left;"></label>
<!--  <input id="company" readonly class="user_input" type="text" name="company"> -->
</p>

<p id="city_3">
<label id="label_city" for="">公司位置</label>
<label id="prov_city"  style="text-align: left;"></label>
<!--  <select id="prov" readonly name="prov" class="prov" style="width: 130px;height: 30px"></select> 
<select id="city" readonly name="city" class="city" style="width: 130px;height: 30px"></select> -->
</p>

<p>
<label id="label_city" for="location">具体地址</label>
<input id="location" class="user_input" type="text" name="location">
</p>

<p>
<label id="label_city" for="contacts">联系人</label>
<input id="contacts" class="user_input" type="text" name="contacts">
</p>

<p>
<label id="label_city" for="mobile">手机</label>
<input id="mobile" class="user_input" type="text" name="mobile">
</p>

<p>
<label id="label_city" for="telphone">公司电话</label>
<input id="telphone" class="user_input" type="text" name="telphone">
</p>

<p>
<label id="label_mail" for="mail">邮箱</label>
<input id="mail" class="user_input" type="text" name="mail">
</p>

<p>
<label id="label_mail" for="mail">开户银行</label>
<label id="bankName" style="text-align: left;"></label>
<!--  <input id="bankName" readonly class="user_input" type="text" name="bankName"> -->
</p>

<p>
<label id="label_mail" for="mail">卡号</label>
<label id="bankCard" style="text-align: left;"></label>
<!--  <input id="bankCard" readonly class="user_input" type="text" name="bankCard"> -->
</p>

<p>
<label id="label_mail" for="mail">持卡人</label>
<label id="bankUser" style="text-align: left;"></label>
<!--  <input id="bankUser" readonly class="user_input" type="text" name="bankUser"> -->
</p>
	<p>
	<label id="label_zzfile">营业执照图片</label>
	<img id="zzfile" height="100px" onclick="showPic()">
	<span id="img" style="display: none"><img id="showfile" ></span>
<c:if test="${sessionInfo.state !=0 }">
	<input type="file" name="file" class="layui-upload-file" lay-title="添加文件">
	<br>
	<span id="uptip"></span><span id="successText" style="color:#67ccea"></span>
</c:if>
</p>
<p>
	<label id="label_remark" >备注</label>
	<span>${sessionInfo.remark}</span>
</p>
<div class="clear"></div>
<p>
<c:if test="${sessionInfo.state ==0 }">
<input type="button" class="query" onclick="audit(0)" id="user_submit" style="margin-left:152px;"  value="保存">
</c:if>
<c:if test="${sessionInfo.state !=0 }">
	<input type="button" class="query" onclick="audit(1)" id="user_resubmit" style="margin-left:152px;"  value="提交审核">
</c:if>
</p>
</form>

</div>
<jsp:include page="../footer.jsp"/>
<script src="${ctx }/jslib/layui/layui.js" charset="utf-8"></script>
<script>
	layui.use('upload', function(){
		layui.upload({
			url: '${ctx}/file/uploadRegPic'
			,method: 'post' //上传接口的http类型
			,ext: 'jpg|png|jpeg'
			,success: function(res){
				$("#zzPath").val(res.data.src);
				$("#uptip").html(res.data.name);
				$("#successText").html("上传成功！");
				$("#zzfile").attr("src",res.data.src);
				$("#showfile").attr("src",res.data.src);
			}
		});
	});
</script>
</body>
</html>
